﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FrmClock.Service
{
    internal class FormService
    {
        /// <summary>
        /// 获取
        /// 获取单个显示器显示
        /// </summary>
        /// <param name="s"></param>
        public static void GetSingle(ProgressBar[] bars, int i,int count)
        {

            switch (i)
            {
                case 0:
                    {
                        bars[7*count+0].Value = 100;
                        bars[7*count+1].Value = 0;
                        bars[7*count+2].Value = 100;
                        bars[7*count+3].Value = 100;
                        bars[7*count+4].Value = 100;
                        bars[7*count+5].Value = 100;
                        bars[7*count+6].Value = 100;
                        break;
                    }
                case 1:
                    {
                        bars[7*count+0].Value = 0;
                        bars[7*count+1].Value = 0;
                        bars[7*count+2].Value = 0;
                        bars[7*count+3].Value = 0;
                        bars[7*count+4].Value = 100;
                        bars[7*count+5].Value = 0;
                        bars[7*count+6].Value = 100;
                        break;
                    }
                case 2:
                    {
                        bars[7*count+0].Value = 100;
                        bars[7*count+1].Value = 100;
                        bars[7*count+2].Value = 100;
                        bars[7*count+3].Value = 0;
                        bars[7*count+4].Value = 100;
                        bars[7*count+5].Value = 100;
                        bars[7*count+6].Value = 0;
                        break;
                    }
                case 3:
                    {
                        bars[7*count+0].Value = 100;
                        bars[7*count+1].Value = 100;
                        bars[7*count+2].Value = 100;
                        bars[7*count+3].Value = 0;
                        bars[7*count+4].Value = 100;
                        bars[7*count+5].Value = 0;
                        bars[7*count+6].Value = 100;
                        break;
                    }
                case 4:
                    {
                        bars[7*count+0].Value = 0;
                        bars[7*count+1].Value = 100;
                        bars[7*count+2].Value = 0;
                        bars[7*count+3].Value = 100;
                        bars[7*count+4].Value = 100;
                        bars[7*count+5].Value = 0;
                        bars[7*count+6].Value = 100;
                        break;
                    }
                case 5:
                    {
                        bars[7*count+0].Value = 100;
                        bars[7*count+1].Value = 100;
                        bars[7*count+2].Value = 100;
                        bars[7*count+3].Value = 100;
                        bars[7*count+4].Value = 0;
                        bars[7*count+5].Value = 0;
                        bars[7*count+6].Value = 100;
                        break;
                    }
                case 6:
                    {
                        bars[7*count+0].Value = 100;
                        bars[7*count+1].Value = 100;
                        bars[7*count+2].Value = 100;
                        bars[7*count+3].Value = 100;
                        bars[7*count+4].Value = 0;
                        bars[7*count+5].Value = 100;
                        bars[7*count+6].Value = 100;
                        break;
                    }
                case 7:
                    {
                        bars[7*count+0].Value = 100;
                        bars[7*count+1].Value = 0;
                        bars[7*count+2].Value = 0;
                        bars[7*count+3].Value = 0;
                        bars[7*count+4].Value = 100;
                        bars[7*count+5].Value = 0;
                        bars[7*count+6].Value = 100;
                        break;
                    }
                case 8:
                    {
                        bars[7*count+0].Value = 100;
                        bars[7*count+1].Value = 100;
                        bars[7*count+2].Value = 100;
                        bars[7*count+3].Value = 100;
                        bars[7*count+4].Value = 100;
                        bars[7*count+5].Value = 100;
                        bars[7*count+6].Value = 100;
                        break;
                    }
                case 9:
                    {
                        bars[7*count+0].Value = 100;
                        bars[7*count+1].Value = 100;
                        bars[7*count+2].Value = 100;
                        bars[7*count+3].Value = 100;
                        bars[7*count+4].Value = 100;
                        bars[7*count+5].Value = 0;
                        bars[7*count+6].Value = 100;
                        break;
                    }
            }
        }
        /// <summary>
        /// 使显示器显示当前时间
        /// </summary>
        /// <param name="Bars"></param>
        /// <param name="i"></param>
        /// <param name="count"></param>
        public static void GetTimeNow(ProgressBar[] Bars,int i,int count)
        {
            //显示时间
            switch (i)
            {
                case 0:
                    {
                        int x = Convert.ToInt32(DateTime.Now.Hour.ToString()) / 10;
                        FormService.GetSingle(Bars, x,count);
                        break;
                    }
                case 1:
                    {
                        int x = Convert.ToInt32(DateTime.Now.Hour.ToString()) % 10;
                        FormService.GetSingle(Bars, x,count);
                        break;
                    }
                case 2:
                    {
                        int x = Convert.ToInt32(DateTime.Now.Minute.ToString()) / 10;
                        FormService.GetSingle(Bars, x,count);
                        break;
                    }
                case 3:
                    {
                        int x = Convert.ToInt32(DateTime.Now.Minute.ToString()) % 10;
                        FormService.GetSingle(Bars, x,count);
                        break;
                    }
                case 4:
                    {
                        int x = Convert.ToInt32(DateTime.Now.Second.ToString()) / 10;
                        FormService.GetSingle(Bars, x,count);
                        break;
                    }
                default:
                    {
                        int x = Convert.ToInt32(DateTime.Now.Second.ToString()) % 10;
                        FormService.GetSingle(Bars, x,count);
                        break;
                    }
            }
        }
        public static void GetTest(ProgressBar[] Bars)
        {
            ProgressBar Btn = Bars[0];
            Btn.Value = 100;
            Bars[0] = Btn;
        }
        public static void GetTimeChange(ProgressBar[]Bars)
        {
            
                int hf=Convert.ToInt32(DateTime.Now.Hour.ToString())/10;
                int hl=  Convert.ToInt32(DateTime.Now.Hour.ToString())%10;
                int mf = Convert.ToInt32(DateTime.Now.Minute.ToString())/10;
                int ml = Convert.ToInt32(DateTime.Now.Minute.ToString())%10;
                int sf = Convert.ToInt32(DateTime.Now.Second.ToString())/10;
                int sl = Convert.ToInt32(DateTime.Now.Second.ToString())%10;
                GetSingle(Bars, hf, 0);
                GetSingle(Bars, hl, 1);
                GetSingle(Bars, mf, 2);
                GetSingle(Bars, ml, 3);
                GetSingle(Bars, sf, 4);
                GetSingle(Bars, sl, 5);
        }
    }
}
